package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Review;
import cn.wolfcode.trip.base.service.IReviewService;
import cn.wolfcode.trip.base.service.IReviewService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/review")
public class ReviewController {
    @Autowired
    private IReviewService reviewService;
    @GetMapping
    public Object getReview(Long id,String types){
        List<Review> reviews = reviewService.selectReviewByUserId(id, types);
        return reviews;
    }


    @PutMapping("/changeState/{travelId}")
    public Object changeState(@PathVariable Long travelId){
        reviewService.changeState(travelId);
        return new JSONResult();
    }

    @PostMapping
    public  void saveContent( String content, Long userId,  Long travelId ){


        reviewService.save(content,userId,travelId);
    }



    @GetMapping("/{travelId}")
    public  Object getContent(@PathVariable Long travelId ){


        List<Review> list = reviewService.selectContenByTravelId(travelId);
        return list;
    }


}
